﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.IO;

namespace Elentok.Common.Helpers
{
  /// <summary>
  /// Reflection related helper methods
  /// </summary>
  public static class ReflectionHelper
  {
    /// <summary>
    /// Returns a byte-array that contains the data of the requested resource
    /// </summary>
    /// <param name="assembly"></param>
    /// <param name="name">The case-sensitive name of the resource being requested</param>
    /// <returns></returns>
    public static byte[] GetManifestResourceBytes(this Assembly assembly, string name)
    {
      using (Stream stream = assembly.GetManifestResourceStream(name))
      {
        return stream.ReadAllBytes();
      }
    }
  }
}
